<template>
  <div class="nav2">
    <div class="container pt-4">
      <div class="row">
        <div class="col-12">
          <div class="pointsRule">
            <ul id="list">
              <li style="z-index:6;background-image: linear-gradient(to right, #005bea ,#00c6fb)" class="green" @click="gotoHome()"><a><span>首页</span><i style="background-color:#00c6fb"></i></a></li>
              <li style="z-index:5;background-color: #ffc107;"><a><em class="before"></em><span  style="color: #4e555b;">预算管理</span><i style="background-color:#ffc107;"></i></a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="content">
      <ul class="pl-0">
        <li class="text-center">
          <router-link to="/nav3">预算编制</router-link>
        </li>
        <li class="text-center">
          <router-link  to="/manager">
            利润
            <div class="mt-2">当月：{{fixNum(incomeNowMonth - costMonthAmount - costNowMonth)}}万元</div>
            <div class="mt-2">累计：{{fixNum(incomeAmount - cost - costAmount)}}万元</div>
          </router-link>
        </li>
        <li class="text-center">
          <router-link to="/profit">
            收入
            <div class="mt-2">当月：{{fixNum(incomeNowMonth)}}万元</div>
            <div class="mt-2">累计：{{fixNum(incomeAmount)}}万元</div>
          </router-link>
        </li>
<!--        <li class="text-center">-->
<!--          <router-link to="">-->
<!--            成本-->
<!--            <div class="mt-2">当月：{{fixNum(costMonthAmount)}}万元</div>-->
<!--            <div class="mt-2">累计：{{fixNum(cost)}}万元</div>-->
<!--          </router-link>-->
<!--        </li>-->
        <li class="text-center">
          <router-link to="/cost">
            费用
            <div class="mt-2">当月：{{fixNum(costNowMonth)}}万元</div>
            <div class="mt-2">累计：{{fixNum(costAmount)}}万元</div>
          </router-link>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
  export default {
    name: "nav2",
    data () {
      return {
        modules:[
          {
            name:'制定目标',
            toUrl:'/budget'
          },
          {
            name:'文件上传',
            toUrl:'/file'
          }
        ],
        profits: 0, //实际累积利润
        profitsMonth: 0,  //当月利润
        costNowMonth: 0,  //当月费用
        incomeNowMonth: 0,  //当月收入
        costAmount: 0,  //累积费用
        incomeAmount: 0, //累积收入
        incomeTargetAmount: 0,
        costTargetAmount: 0,
        serviceIncome: 0,  //服务费
        cost: 0,
        costTarget: 0,
        costMonthAmount: 0,
        loading: {},
        orgid: window.sessionStorage.getItem('orgid')
      }
    },
    created() {
      this.getAllCost()
      this.getAllIncome()
      this.getAllProfit()
    },
    methods: {
      gotoHome(){
        this.$router.push("/index");
      },
      getAllCost(){
        // this.loading = this.$loading({
        //   lock: true,//lock的修改符--默认是false
        //   text: 'Loading',//显示在加载图标下方的加载文案
        //   spinner: 'el-icon-loading',//自定义加载图标类名
        //   background: 'rgba(0, 0, 0, 0.7)',//遮罩层颜色
        //   target: document.querySelector('#table')//loadin覆盖的dom元素节点
        // });
        this.$http.get(
          '/api/getCostSum',
          {
            params: {
              type: 3 + this.orgid
            }
          }).then(res => {
          this.costAmount = res.data.sumAmount
          this.costNowMonth = res.data.nowMonthAmount
          this.costTargetAmount = res.data.targetAmount
          // this.loading.close()
        })
      },
      getAllProfit () {
        this.$http.get(
          '/api/getCostSum',
          {
            params: {
              type: 4 + this.orgid
            }
          }).then(res => {
          this.cost = res.data.sumAmount
          this.costMonthAmount = res.data.nowMonthAmount
          this.costTarget = res.data.targetAmount
          window.sessionStorage.setItem('profits', this.incomeTargetAmount - this.costTarget -this.costTargetAmount)
          // this.loading.close()
        })
      },
      getAllIncome(){
        this.$http.get(
          '/api/getCostSum',
          {
            params: {
              type: 1 + this.orgid
            }
          }).then(res => {
          this.incomeAmount = res.data.sumAmount
          this.incomeNowMonth = res.data.nowMonthAmount
          this.incomeTargetAmount = res.data.targetAmount

          // this.loading.close()
        })
      },
      fixNum (num) {
        return (num/10000).toFixed(2)
      },
    }
  }
</script>

<style scoped>
  .breadcrumb{
    padding: 10px 5px;
    padding-bottom: 5px;
    background: transparent;
  }
  .breadcrumb-item a,
  .breadcrumb-item{
    font-size: 20px;
  }
  .nav2{
    height: 100%;
    /*background: url("~@/assets/img/bg4.png") no-repeat;*/
    background-size: 100% auto;
    background-position: 0 -100px;
  }
  .content{
    padding-top: 8%;
  }
  .content ul{
    display: flex;
    flex-direction: row;
    justify-content: center;
  }
  .content ul li{
    list-style: none;
    display: inline;
  }
  .content ul li a{
    /*background: ;*/
    color: #4e555b;
    display: inline-block;
    margin: 40px;
    border-radius: 10px;
    width: 210px;
    height: 150px;
    font-size: 24px;
    font-weight: bold;
    /*box-shadow: 0 0 10px #95999c;*/
    border: 4px solid #a0cfff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-decoration: none;
  }
  .content ul li a div{
    font-size: 16px;
    font-weight: normal;
    color: #95999c;
    font-weight: bold;

  }
</style>
